<script setup lang="ts">
import useUserStore from '@/store/user/user'
import type { ElForm } from 'element-plus'
import { reactive, ref } from 'vue'

// 引入useUserStore
const userStore = useUserStore()

//1. 定义form的数据
const searchForm = reactive({
  name: '',
  realname: '',
  cellphone: '',
  enable: 1,
  createAt: ''
})

// 2.重置表单
const formRef = ref<InstanceType<typeof ElForm>>()
const handleRefreshForm = () => {
  // // 1.清空输入框的数据
  formRef.value?.resetFields()
  // // 2.请求新的数据
  // userStore.postUsersListDataAction()
}

// 3.查询数据
const handleSearchClick = () => {
  // 1.调用useUserStore的请求数据接口
  // userStore.postUsersListDataAction(searchForm)
}
</script>

<template>
  <div class="user-search">
    <div class="search">
      <el-form :model="searchForm" ref="formRef" label-width="80px" size="large">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="商品名称" prop="name">
              <el-input v-model="searchForm.name" placeholder="请输入商品名称" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="商品地址" prop="realname">
              <el-input v-model="searchForm.realname" placeholder="请输入商品地址" />
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="状态" prop="enable">
              <el-select v-model="searchForm.enable" placeholder="请选择的状态" style="width: 100%">
                <el-option label="可用" :value="1" />
                <el-option label="下架" :value="0" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="创建时间" prop="createAt">
              <el-date-picker
                v-model="searchForm.createAt"
                type="daterange"
                range-separator="-"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="btn">
      <el-button icon="Refresh" @click="handleRefreshForm">重置</el-button>
      <el-button type="primary" icon="Search" @click="handleSearchClick">查询</el-button>
    </div>
  </div>
</template>

<style lang="less" scoped>
.user-search {
  padding: 25px 80px 20px 0px;
  background-color: #fff;
  border-radius: 5px;

  .el-form-item {
    padding: 25px 0 25px 50px;
    margin-bottom: 0;
  }
  .btn {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 10px;
  }
}
</style>
